import random from './random.js'
import md5Libs from '@/uview-ui/libs/function/md5'
import setting from '@/settings/projectSetting.js'
import sortingArray from './sortingArray.js'
export default {
  /**
   * @description 接口签名验证
   * @param {string} t 时间戳
   * @param {string} n 签名字符串
   */
  secretdate: function (params, t = null, n = null) {
    var timestamp = t || Math.round(new Date() / 1000)
    var nonce = n || random.random_char(32)
    const signString =
      setting.appKey + '|' + sortingArray.objKeySort(params) + '|' + timestamp + '|' + nonce
    var data_for_sign = md5Libs.md5(signString)
    return {
      'E-APP-TIMESTAMP': timestamp,
      'E-APP-NONCE': nonce,
      'E-APP-SIGN': data_for_sign,
    }
  },
}
